home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / ae.lha / ae / AEC / aec-file-prologue < prev    next >
Text File  |  1990-02-28  |  3KB  |  131 lines

  1. /* This file is automatically produced by AEC.  Do NOT edit. */
  2.  
  3. /* aec-file-prologue.
  4.    Boiler plate prologue code for files produced by AEC.
  5.    Copyright (C) 1989, 1990 by James R. Larus (larus@cs.wisc.edu).
  6.  
  7.    AE and AEC are free software; you can redistribute it and/or modify it
  8.    under the terms of the GNU General Public License as published by the
  9.    Free Software Foundation; either version 1, or (at your option) any
  10.    later version.
  11.  
  12.    AE and AEC are distributed in the hope that it will be useful, but
  13.    WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.    General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU General Public License
  18.    along with GNU CC; see the file COPYING.  If not, write to James R.
  19.    Larus, Computer Sciences Department, University of Wisconsin--Madison,
  20.    1210 West Dayton Street, Madison, WI 53706, USA or to the Free
  21.    Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  22.  
  23.  
  24. /* $Header: /var/home/larus/AE/AEC/RCS/aec-file-prologue,v 2.0 90/02/09 17:23:39 larus Exp Locker: larus $ */
  25.  
  26.  
  27. #include <sys/file.h>
  28. #include <setjmp.h>
  29. #include <stdio.h>
  30. #include "aec.h"
  31.  
  32. static FILE *__ae_in_file;
  33.  
  34.  
  35. #ifdef BYTES_BIG_ENDIAN
  36. #define B_TO_H(b1, b2) (b2 | (b1 << 8))
  37. #else
  38. #define B_TO_H(b2, b1) (b2 | (b1 << 8))
  39. #endif
  40.  
  41.  
  42. #define GET_WORD(d) {d = getw (__ae_in_file); \
  43.              if (feof (__ae_in_file)) eof_err ();}
  44.  
  45. #define GET_HALF(d) {d = getc (__ae_in_file); \
  46.              d = B_TO_H (d, getc (__ae_in_file)); \
  47.              if (feof (__ae_in_file)) eof_err ();}
  48.  
  49. #define GET_BYTE(d) {d = getc (__ae_in_file); \
  50.              if (feof (__ae_in_file)) eof_err ();}
  51.  
  52.  
  53. #define EAT_HALF() {getc (__ae_in_file); getc (__ae_in_file); \
  54.             if (feof (__ae_in_file)) eof_err ();}
  55.  
  56. #define EAT_BYTE() {getc (__ae_in_file); \
  57.             if (feof (__ae_in_file)) eof_err ();}
  58.  
  59.  
  60.  
  61. static void eof_err()
  62. {
  63.   fprintf(stderr, "Read beyond end of event file.\n");
  64.   exit(-1);
  65. }
  66.  
  67.  
  68. static int temp;
  69.  
  70. static void (*out_func)();
  71.  
  72.  
  73. #define ISSUE_INST(n) {out_func(INST_REF, PC, n); PC += 4 * n;}
  74.  
  75. #define READ_MEM(x) out_func(MEM_READ, x)
  76.  
  77. #define WRITE_MEM(x) out_func(MEM_WRITE, x)
  78.  
  79. #define LOOP_START(n) out_func(START_LOOP, n)
  80.  
  81. #define LOOP_CONT(n) out_func(CONT_LOOP, n)
  82.  
  83. #define LOOP_END(n) out_func(END_LOOP, n)
  84.  
  85.  
  86. static void cjump_err()
  87. {
  88.   fprintf(stderr, "Target of jump unknown.\n");
  89.   exit(-1);
  90. }
  91.  
  92.  
  93. static void func_err()
  94. {
  95.   fprintf(stderr, "Event PC does not match address of function.\n");
  96.   exit(-1);
  97. }
  98.  
  99.  
  100. typedef int (*PFI)();
  101. static PFI address_to_callee();
  102.  
  103.  
  104. /* Exit returns to top level in AE_RECREATE. */
  105.  
  106. static jmp_buf __ae_top_level_env;
  107.  
  108. static int __ae_exit () {longjmp(__ae_top_level_env, 1);}
  109.  
  110. static int __ae__exit () {longjmp(__ae_top_level_env, 1);}
  111.  
  112.  
  113. /* Used in debugging mode: */
  114.  
  115. #define SVI(var, value) {if (var != (int *) -1) \
  116.               *var = value; \
  117.             else \
  118.               { \
  119.                 var = (int *) malloc(sizeof(int)); \
  120.                 *var = value; \
  121.               }}
  122.  
  123.  
  124. #define SVF(var, value) {if (var != (int *) -1) \
  125.               *var = value; \
  126.             else \
  127.               { \
  128.                 var = (float *) malloc(sizeof(float)); \
  129.                 *var = value; \
  130.               }}
  131.